package org.seven.jrdp.web.t;

import java.util.List;

import org.seven.jrdp.biz.t.model.TYs;
import org.seven.jrdp.biz.t.service.TYsService;
import org.seven.jrdp.commons.model.Result;
import org.seven.jrdp.commons.util.JsonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

@RestController
@RequestMapping("/mgt/t/ys")
public class TYsController {
	@Autowired
	private TYsService tYsService;

	@GetMapping("/{view}")
	public ModelAndView view(@PathVariable String view) {
		return new ModelAndView("mgt/t/ys/ys_" + view);
	}

	@PostMapping("/find")
	public List<TYs> find() {
		List<TYs> list = tYsService.find();
		return list;
	}

	@RequestMapping("/save")
	public Result save(String json) {
		List<TYs> list = JsonUtils.getList(json, TYs.class);
		tYsService.save(list);
		return Result.SUCCESS;
	}
}